package top.yudoge.dogeeditor.commons.web

data class Response<T> (
    val code: String,
    val message: String?,
    val data: T?,
) {

    val successed: Boolean
        get() = code == "0"

    companion object {
        fun <T> success(data: T? = null): Response<T> {
            return Response("0", null, data)
        }

        fun <T> fail(code: String, message: String? = null): Response<T> {
            return Response(code, message, null)
        }
    }

}